import com.blade.Blade;

public class Test {

  public static void main(String[] args) throws Exception {
    Blade.of().post("/api/preview", ctx -> {
      WordParser parser = new WordParser();
      ctx.request().fileItem("doc").ifPresent(fileItem -> {
        try {
          if (fileItem.getFileName().endsWith(".docx")) {
            String html = parser.parseDocx(fileItem.getData());
            ctx.text(html);
          } else if (fileItem.getFileName().endsWith(".doc")) {
            String html = parser.parseDoc(fileItem.getData());
            ctx.text(html);
          } else {
            ctx.text("FAILED");
          }
        } catch (Exception e) {
          System.out.println(e.getMessage());
          e.printStackTrace();
        }
      });
    }).start();
    // WordParser parser = new WordParser();
    // System.out.println(parser.parseDocx());
    // parser.parseDoc();
  }
}
